@layout("/common/_container.html"){
<script type="text/javascript">
    $(function () {
        $("#btn_close").bind("click", function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });
        $("#btn_save").bind("click", function () {
            var ids = Feng.zTreeCheckedNodes("zTree");
            var ajax = new $ax(Feng.ctxPath + "/mgr/setOutpatientDepartment", function (data) {
                Feng.success("分配门诊角色成功!");
                window.parent.MgrUser.table.refresh();
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            }, function (data) {
                alert("没有权限，请联系系统管理员！")
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            });
            ajax.set("roleIds", ids);
            ajax.set("userId", "${userId}");
            ajax.start();
        });
        initZtree();
    });

    function initZtree() {
        var setting = {
            check: {
                enable: true,
                chkboxType: {
                    "Y": "",
                    "N": ""
                }
            },
            data: {
                simpleData: {
                    enable: true
                }
            }
        };
        var ztree = new $ZTree("zTree", "/outpatientManagement/outpatientManagementTreeListByUserId/${userId}");
        ztree.setSettings(setting);
        ztree.init();
    }
</script>
<div class="container" style="padding: 0px 10px !important; margin-top: -10px; text-align: center !important;">
    <div class="row">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>${userAccount!}</h5>
            </div>
            <div class="ibox-content">
                <ul id="zTree" class="ztree"></ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <button class="btn btn-sm btn-info" type="button" id="btn_save">
                <i class="ace-icon fa fa-check bigger-110"></i> 保存
            </button>
            &nbsp;
            <button class="btn btn-sm btn-danger" type="button" id="btn_close">
                <i class="ace-icon fa fa-close bigger-110"></i> 关闭
            </button>
        </div>
    </div>
</div>
@}